/**
 * $Id: LazyDoubleCheckSingleton.java,v 1.0 2022/6/5 20:59 shidesheng Exp $
 * <p>
 * Copyright 2021 Sinosoft Co.,Ltd. All rights reserved.
 */
package sds.mode.single.lazy.doublelock;


/**
 * @author shidesheng
 * @version $Id: LazyDoubleCheckSingleton.java,v 1.1 2022/6/5 20:59 shidesheng Exp $
 * Created on 2022/6/5 20:59
 *
 *  单例模式双重检查锁
 *  优点：
 *  线程安全，性能高
 *  缺点：
 *  可读性难度大，不够优雅
 */
public class LazyDoubleCheckSingleton {

	public static LazyDoubleCheckSingleton lazySingleton = null;

	private LazyDoubleCheckSingleton(){}

	public static LazyDoubleCheckSingleton getInstance() {
		if (lazySingleton == null ) {
			synchronized (LazyDoubleCheckSingleton.class){
				if (lazySingleton == null ){
					lazySingleton = new LazyDoubleCheckSingleton();
				}
			}
		}
		return lazySingleton;
	}

}
